/*
 * PDLogger
 * 
 * Copyright (c) 2012, Zoujie Wu <yibn2008@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 *   * Redistributions of source code must retain the above copyright notice, this 
 *     list of conditions and the following disclaimer.
 *   
 *   * Redistributions in binary form must reproduce the above copyright notice, 
 *     this list of conditions and the following disclaimer in the documentation 
 *     and/or other materials provided with the distribution.
 *   
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/* $Id$ */

#ifndef PDL_WATCH_H
#define PDL_WATCH_H

/* define common watch constants */
#define PDL_MAX_WATCH_FUNCS	256
#define PDL_LABEL_LOAD		"Load"
#define PDL_LABEL_WATCH		"Watch"
#define PDL_LABEL_STATUS	"Status"
#define PDL_MSG_WATCH_ERROR "Catch a php error (level = %s)"
#define PDL_MSG_LOAD_FILE	"Load a php file %s in %.3f msec(s)"
#define PDL_MSG_STATUS		"PHP runtime status"

#define BYTES_IN_MB			(1024 * 1024)
#define BYTES_IN_KB			1024

/* define watch item */
#define PDL_W_ERROR			(1<<0L)			/* Watch all errors */
#define PDL_W_LOAD			(1<<1L)			/* Watch the loaded files */
#define PDL_W_PDO			(1<<2L)			/* Watch the PDO operation */
#define PDL_W_FUNC			(1<<3L)			/* Watch the modified function */
#define PDL_W_STATUS		(1<<4L)			/* Watch the php execution status */

#define PDL_W_ALL			PDL_W_ERROR | PDL_W_LOAD | PDL_W_PDO | PDL_W_FUNC | PDL_W_STATUS

/* define internal watch APIs */
PDL_API void pdl_register_watch_hooks(TSRMLS_D);
PDL_API void pdl_unregister_watch_hooks(TSRMLS_D);
PDL_API pdl_record_t* pdl_get_watch_status(TSRMLS_D);

/* {{{ ARG_INFO
 */
ZEND_BEGIN_ARG_INFO(pdl_watch_arginfo, 0)
	ZEND_ARG_INFO(0, items)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(pdl_watch_func_arginfo, 0, 0, 1)
	ZEND_ARG_INFO(0, func)
	ZEND_ARG_INFO(0, callback)
ZEND_END_ARG_INFO()
/* }}} */

/* define php watch APIs */
PHP_FUNCTION(pdl_watch);
PHP_FUNCTION(pdl_watch_func);

#endif	/* PDL_WATCH_H */
/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: noet sw=4 ts=4 fdm=marker
 * vim<600: noet sw=4 ts=4
 */
